filename = 'programming.txt'
# 写入模式
with open(filename,'w') as file_object:
    file_object.write('zhangshanlisiwangermazi')
    file_object.write(' test ')
    file_object.write('zangssan\n')
    file_object.write('llllll\n')

# 附加模式
with open(filename,'a') as file_object:
    file_object.write("I also love finding meaning in large datasets.\n")
    file_object.write("I love creating apps that can run in a browser.\n")